package email;

/**
 * @author LIBOFEI
 * @ClassName ErrorTest
 * @description
 * @date 2021/3/5 09:52
 * @Version 1.0
 **/
public class ErrorTest {

    public static void main(String[] args) {
//        replaceTwo("13810388495@@163.com");
//        replaceSpace("angeldsajkl @163.com");
//        replaceThree("136@095594@qq.com");
//        replaceFour("2825411964qq@.com");
          replaceFive("@787898156qq.com");
          replaceFive("1369119720@qq.com");
//          replaceSix("984592571@.qq.com");
//          replaceSeven("@qq1849897557.com");
//          replaceEight("1183268217@.QQ.con");
//          replaceNine("427905029@qq，com");
        replaceEleven("1369119720@我qq.com");
        replaceEleven("1369119720@qq.com");
//        replaceTwelve("@1943469107");
    }

    public static void replaceTwo(String errorEmail){
        errorEmail = errorEmail.replaceAll("@@","@");
        System.out.println(errorEmail);
    }

    public static void replaceSpace(String errorEmail){
        errorEmail = errorEmail.replaceAll(" ","");
        System.out.println(errorEmail);
    }

    public static void replaceThree(String errorEmail){
        if(errorEmail.contains("@")){
            int first = errorEmail.indexOf("@");
            int last = errorEmail.lastIndexOf("@");
            if(first != last){
                //出现两次@,把第一次去掉
                errorEmail = errorEmail.substring(0,first) + errorEmail.substring(first + 1);
                System.out.println(errorEmail);
            }
        }
    }

    public static void replaceFour(String errorEmail){
        errorEmail = errorEmail.replaceAll("qq@","@qq");
        System.out.println(errorEmail);
    }


    public static void replaceFive(String errorEmail){
        if(errorEmail.startsWith("@")){
            if(errorEmail.contains("qq")){
                int index = errorEmail.indexOf("qq");
                errorEmail = errorEmail.substring(1,index) + "@" + errorEmail.substring(index);
                System.out.println(errorEmail);
            }
        }
    }

    public static void replaceSix(String errorEmail){
        errorEmail = errorEmail.replaceAll("@.","@");
        System.out.println(errorEmail);
    }


    public static void replaceSeven(String errorEmail){
        if(errorEmail.startsWith("@qq")){
            if(errorEmail.contains(".com")){
                int index = errorEmail.indexOf(".com");
                errorEmail = errorEmail.substring(3,index) + "@qq" + errorEmail.substring(index);
            }
            System.out.println(errorEmail);
        }
    }


    public static void replaceNine(String errorEmail){
        errorEmail = errorEmail.replaceAll("，","com");
        System.out.println(errorEmail);
    }

    public static void replaceTen(String errorEmail){
        errorEmail = errorEmail.toLowerCase();
        System.out.println(errorEmail);
    }

    public static void replaceEleven(String errorEmail){
       if(errorEmail.contains("@") && errorEmail.contains("qq")){
           int one = errorEmail.indexOf("@");
           int two = errorEmail.indexOf("qq");
           if(two > one && (one+1)!=two){
               errorEmail = errorEmail.substring(0,one+1) + errorEmail.substring(two);
               System.out.println(errorEmail);
           }
       }
    }

    public static void replaceTwelve(String errorEmail){
        if(errorEmail.startsWith("@") && !errorEmail.contains("qq") && !errorEmail.contains(".com")){
            errorEmail = errorEmail.substring(1) + "@qq.com";
            System.out.println(errorEmail);
        }
    }
}
